﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.Finance.Querys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp;

namespace mozhi.smarterp.Finance.Accounts
{
    [RemoteService]
    [Route("api/v1/accounts")]
    public class AccountController : BaseController
    {
        private IAccountAppService _appService;

        public AccountController(IAccountAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [Route("all")]
        public async Task<List<AccountDto>> GetAllAsync(string keyword, bool? activated , bool includeDetail)
        {
            var result = await _appService.GetListAsync(new AccountQuery() { Keyword = keyword, Activated = activated , IncludeDetail= includeDetail });

            return result;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<AccountDto> GetAsync(Guid id)
        {
            var result = await _appService.GetAsync(id);

            return result;
        }


        [HttpPost]
        public async Task<AccountDto> CreateAsync(AccountCreateDto dto)
        {
            var result = await _appService.CreateAsync(dto);

            return result;
        }

        [HttpPut]
        public async Task<AccountDto> UpdateAsync(AccountUpdateDto dto)
        {
            var result = await _appService.UpdateAsync(dto);

            return result;
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }
    }
}
